package com.allwees.bs.c.module.ops.req;

import com.allwees.bs.core.modelbase.req.SignedReq;
import com.allwees.bs.core.modelbase.validate.ValidateItem;
import com.allwees.core.common.constant.EPlatform;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;

/**
 * @Author linqiu
 * @create 2019/10/31 16:36
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class SubscriptionReq extends SignedReq {

    private EPlatform platform;

    private String email;

    @Override
    public ValidateItem[] getValidateItems() {
        return ArrayUtils.addAll(super.getValidateItems(),
                new ValidateItem(StringUtils.isBlank(email), "email can not be empty"),
                new ValidateItem(platform == null, "platform can not be a null"));
    }

    @Override
    public Object[] signValues() {
        return new Object[]{email, platform.name(), getTime().getTime()};
    }

    @Override
    public String signSeparator() {
        return platform.isApp() ? "_SEDM_" : "_SED_";
    }
}
